﻿namespace AttrSer
{
    using System;
    using System.Xml.Serialization;
    using System.Xml;
    using PErsonMimi;
    using System.IO;
    public static class Ser
    {
        public static void Serialize(Object serializableObject,ref string pstring)
        {
            try
            {
                XmlSerializer serializer = new XmlSerializer(serializableObject.GetType());
               // XmlWriter writer = XmlWriter.Create("ser.xml");
                using (TextWriter sw = File.AppendText("ser.xml"))
                {
                    serializer.Serialize(sw, serializableObject);
                    pstring= sw.NewLine;
                };
                //serializer.Serialize(writer, serializableObject);
               // writer.Close();
            }
            catch (XmlException e)
            {
                Console.WriteLine(e.Message);
                
            }
        }

        public static Person DSerialize(string path)
        {
            XmlSerializer serializer = new XmlSerializer(typeof(Person));
            XmlReader reader = XmlReader.Create(path);
            return (Person)serializer.Deserialize(reader);
        }
    }
}

